<?php
require('../../../wp-config.php');
$plugin_url = trailingslashit( WP_PLUGIN_URL.'/'. dirname( plugin_basename(__FILE__)));
global $wpdb;
$row = $wpdb->get_row("SELECT * FROM wp_house WHERE id=".intval($_GET['id']));
?>
<script type="text/javascript" src="<?php echo $plugin_url;?>lightbox/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo $plugin_url;?>lightbox/js/jquery.lightbox-0.5.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $plugin_url;?>lightbox/css/jquery.lightbox-0.5.css" media="screen" />
<script type="text/javascript">
jQuery(function() {
	// Use this example, or...
	jQuery('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
	// This, or...
	jQuery('a').lightBox(); // Select all links in object with gallery ID
	// This, or...
	jQuery('a.lightbox').lightBox(); // Select all links with lightbox class
	// This, or...
	jQuery('a').lightBox(); // Select all links in the page
	// ... The possibility are many. Use your creative or choose one in the examples above
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<center>
    <h3 style="color:#000080"><?php echo $row->name;?></h3>
    
    <?php echo $row->code;?><p></p>
    <img src="<?php echo $wpdb->get_var("SELECT link FROM wp_image WHERE id_house=".$row->id." AND main=1"); ?>" width="300"/><br />
    <p></p>
    <?php foreach($wpdb->get_results("SELECT * FROM wp_image WHERE id_house=".$row->id." AND main = 0") as $image):
            $duoi = substr($image->link,-4);
            $type = substr($image->link,-11);

      ?>
    <a href="<?php echo $image->link;?>"><img src="<?php echo str_replace($type,'',$image->link).'150x150'.$duoi;?>" /></a>&nbsp;
     <?php endforeach;?><br />
    <?php echo nl2br($row->description);?>
    <br /><b>Price:</b><?php echo $row->price;?>&nbsp;$
    <?php if($row->address != ''){?>
     <br /><b>Address:</b><?php echo $row->address;?>
    <?php }?>
    <?php if($row->bed_room > 0){
        echo '<br /><b>Bed room:</b>';
        echo str_replace(4,'4 or more',$row->bed_room);
    }
    ?>
     <br /><b>Property Type:</b><?php
     $type = array(
        '2'=>'Single Family',
               '3'=>'Cottage',
               '4'=>'Duplex or Condo'
     );
     echo $type[$row->type];
     ?>
     <br /><b>Location:</b><?php
     $location = array(
               2=>'Barnstable',
               3=>'Boston',
               4=>'Bourne',
               5=>'Brewster',
               6=>'Cape Cod',
               7=>'Centerville',
               8=>'Chatham',
               9=>'Cohasset',
               10=>'Cotuit',
               11=>'Craigville',
               12=>'Cummaquid',
               13=>'Dennis',
               14=>'Falmouth',
               15=>'Great Island',
               16=>'Harwich',
               17=>'Hyannis',
               18=>'Hyannisport',
               19=>'Marion',
               20=>'Marstons Mills',
               21=>'Mashpee',
               22=>'Nantucket',
               23=>'New Seabury',
               24=>'Orleans',
               25=>'Osterville',
               26=>'Other',
               27=>'Pocasset',
               28=>'Popponessett',
               29=>'Sandwich',
               30=>'Willowbend',
               31=>'Woods Hole',
               32=>'Yarmouth'
     );
     echo $location[$row->location];
     foreach($wpdb->get_results("SELECT * FROM wp_category") as $category):
echo '<div style="background-color:#CCCCCC;color:white;font-weight: bold;margin-top:10px;">'.$category->name.'</div>
<br />';
foreach($wpdb->get_results("SELECT * FROM wp_attribute WHERE category=".$category->id." AND id IN(SELECT id_att FROM wp_value WHERE id_house = ".$row->id.")") as $ro){echo  '&nbsp;'.$ro->name.'&nbsp;';}
endforeach;
     ?>

</center>